/**
 * bushaofeng. 2011.8.27
 * bs_log.h
 * history:
 */

#ifndef __BS_LOG_H_
#define __BS_LOG_H_

#include <stdio.h>
#include <sys/syslog.h>
#include "bs_type.h"
#include "bs_def.h"
#include "bs_error.h"

#ifdef __cplusplus
extern "C"{
#endif

#define LOG_NUM         8

const static char*      _LOG_NAME[] = {
    "EMERG",
    "ALERT",
    "CRIT",
    "ERR",
    "WARNING",
    "NOTICE",
    "INFO",
    "DEBUG"
};

typedef struct{
    char        path[BS_DEF_STRLEN];
    FILE*       type_file[LOG_NUM];
    FILE*       file;
    int         flag[LOG_NUM];
    struct tm   ltm;
}bs_log_t;

int bs_log_type(const char* name);
// 默认开启fatal日志
int bs_log_init(bs_log_t* plog, const char* path);
int bs_log_set(bs_log_t* plog, int log, int flag);
int bs_log_setflag(bs_log_t* plog, const int* flag, size_t size);
int bs_log_close(bs_log_t* plog);
int bs_log(bs_log_t* plog, int log, const char fmt[], ...);

#ifdef __cplusplus
}
#endif
#endif
